from django.db import models

# Create your models here.


class ContentCategory(models.Model):
    """
    内容分类表：一级类目 如首页 车辆详情页 车辆搜索结果页
            二级类目 如 轮播图、小广告、大广告
            ……
            ……
    """
    content_category_status = (
        (1,'正常'),
        (2,'删除'),
    )
    parent_id = models.ForeignKey('self',on_delete=models.SET(0),verbose_name='父id（0为一级类目）')
    name = models.CharField(max_length=20,verbose_name='分类名称')
    index = models.IntegerField(verbose_name='排序顺序')
    status = models.IntegerField(choices=content_category_status,verbose_name='分类状态')
    create = models.DateTimeField(verbose_name='创建时间')
    update = models.DateTimeField(verbose_name='更新时间')

    class Meta:
        db_table = 'tb_content_category'
        verbose_name = '内容分类'
        verbose_name_plural = verbose_name



class ContentPic(models.Model):
    image = models.ImageField(upload_to='images',verbose_name='上传图片')
    image_alt = models.CharField(max_length=50,verbose_name='图片名称')
    content_id = models.ForeignKey('Content',on_delete=models.CASCADE,verbose_name='所属内容id')


    class Meta:
        db_table = 'tb_content_pic'
        verbose_name = '内容图片'
        verbose_name_plural = verbose_name


class Content(models.Model):
    categary_id = models.ForeignKey('ContentCategory',on_delete=models.CASCADE,verbose_name='所属内容id')
    sort_by = models.IntegerField(verbose_name='展示顺序')
    url = models.CharField(max_length=100,verbose_name='链接')
    text1 = models.CharField(max_length=50,verbose_name='文本内容1')
    text2 = models.CharField(max_length=50,verbose_name='文本内容2')
    text3 = models.CharField(max_length=50,verbose_name='文本内容3')
    text4 = models.CharField(max_length=50,verbose_name='文本内容4')
    text5 = models.CharField(max_length=50,verbose_name='文本内容5')
    create = models.DateTimeField(verbose_name='创建时间')
    update = models.DateTimeField(verbose_name='更新时间')

    class Meta:
        db_table = 'tb_content'
        verbose_name = '内容'
        verbose_name_plural = verbose_name

